import { getArticle, getComment } from '@/api/workbench'
const state = {
  articleList: [],
  commentList: [],
  page: 1,
  pageSize: 6
}

const mutations = {
  articleList(state, val) {
    state.articleList = val
  },
  commentList(state, val) {
    state.commentList = val
  }
}

const actions = {
  getArticleList({ commit, state }) {
    const { page, pageSize } = state
    getArticle({ page, pageSize }).then(res => {
      commit('articleList', res.data[0])
    })
  },
  getCommentList({ commit, state }) {
    const { page, pageSize } = state
    getComment({ page, pageSize }).then(res => {
      commit('commentList', res.data[0])
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
